import { SetMetadata } from '@nestjs/common';

/**
 * 响应装饰器
 * 基于 NestJS 装饰器实现
 * 对应 Java: @ResponseBody
 */

export const RESPONSE_MESSAGE_KEY = 'response_message';
export const RESPONSE_CODE_KEY = 'response_code';

/**
 * 设置响应消息
 */
export const ResponseMessage = (message: string) =>
  SetMetadata(RESPONSE_MESSAGE_KEY, message);

/**
 * 设置响应代码
 */
export const ResponseCode = (code: string) =>
  SetMetadata(RESPONSE_CODE_KEY, code);

/**
 * 成功响应装饰器
 */
export const SuccessResponse = (
  message: string = '操作成功',
  code: string = 'SUCCESS',
) => {
  return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
    SetMetadata(RESPONSE_MESSAGE_KEY, message)(target, propertyKey, descriptor);
    SetMetadata(RESPONSE_CODE_KEY, code)(target, propertyKey, descriptor);
  };
};

/**
 * 分页响应装饰器
 */
export const PaginatedResponse = (message: string = '查询成功') => {
  return SetMetadata(RESPONSE_MESSAGE_KEY, message);
};
